package itsm.isperp.module.controller.slm;

import itsm.isperp.framework.web.response.ResultMessage;
import itsm.isperp.module.service.slm.SlmServiceAgreementManualService;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("slm/serviceAgreementManual")
public class SlmServiceAgreementManualController {

	/**
	 * 
	 */
	@Autowired
	protected SlmServiceAgreementManualService slmServiceAgreementManualService;

	@RequestMapping(value = { "", "manage", "manageView" })
	public ModelAndView manage(HttpServletRequest req) {
		ModelAndView mv = new ModelAndView("slm/serviceAgreementManual/manage");

		return mv;
	}

	@RequestMapping(value = { "resetDeadline" })
	@ResponseBody
	public ResultMessage resetDeadline(String tableName, String columnName,
			String fromDateColumn, String sqlCondition, HttpServletRequest req)
			throws Exception {

		SlmServiceAgreementManualService.resetDeadline(tableName, columnName,
				fromDateColumn, sqlCondition);

		return ResultMessage.success();
	}

	@RequestMapping(value = { "resetTimeDuration" })
	@ResponseBody
	public ResultMessage resetTimeDuration(String tableName, String columnName,
			String fromDateColumn, String toDateColumn, String sqlCondition,
			HttpServletRequest req) throws Exception {

		SlmServiceAgreementManualService.resetTimeDuration(tableName,
				fromDateColumn, toDateColumn, columnName, sqlCondition);

		return ResultMessage.success();
	}
}
